﻿using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Jungle.Code.Core;
using Jungle.Code.DAL;
using System.Collections.Generic;
using Jungle.Code.Utils;
using Jungle.Code.BLL;
using System.Xml;

using Jungle.Code.ProductManager;


    public partial class Products_User : BaseUserModule
	{

        string large = "";
        string pId = "";        
        string sUrl = UrlHelper.GetSiteUrl();


        protected override void OnInit(EventArgs e)
        {
            
            if (Request["pId"] != null)
                pId = Request["pId"];
            if (Request["large"] != null)
                large = Request["large"];


            switch (large)
            {
                case "1":
                    ProductInfo.ActiveViewIndex = 1;
                    PrepareView(Convert.ToInt32(pId));
                    break;
                case "0":
                    ProductInfo.ActiveViewIndex = 0;                    
                    break;
                default:
                    ProductInfo.ActiveViewIndex = 0;
                    break;
            }


            base.OnInit(e);
        }

        //--------------------------------------------------------------------------------
        public void PrepareView(int pId)
        {
            Product p = new Product();
            p.ProductId = pId;
            p.GetByProductId();

            if (p.ImagePath.ToString().Trim() != "no_photo")
            {
                string[] ImagesUrls = p.ImagePath.ToString().Split(',');

                try 
                { 
                    img_LargeImg.ImageUrl = UrlHelper.GetSiteUrl() + ImagesUrls[1].Trim();
                }
                catch(Exception ee)
                {
                    img_LargeImg.ImageUrl = UrlHelper.GetSiteUrl() + "/UserFiles/Images/Content/no_photo.jpg";
                }                          
                
            }
            else 
            {
                img_LargeImg.ImageUrl = UrlHelper.GetSiteUrl() + "/UserFiles/Images/Content/no_photo.jpg";
            }
            
        }
	}
